package web.cms;

import domain.cms.CmsHomePage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import service.facade.user.CmsUserService;
import web.panels.TopMenuPanel;

public class HomePage extends CmsBasePage {
    private final Log log = LogFactory.getLog(getClass());


    @SpringBean
    CmsUserService cmsUserService;
    final IModel pageModel;

    public HomePage() {
        super();
        pageModel = new LoadableDetachableModel<CmsHomePage>() {
            @Override
            protected CmsHomePage load() {
                return cmsUserService.getCmsHomePage();
            }
        };
        add(new Label("content", new PropertyModel<String>(pageModel, CmsHomePage.CONTENT)).setEscapeModelStrings(false));
        add(new Label("pageTitle", new PropertyModel<String>(pageModel, CmsHomePage.TITLE)).setEscapeModelStrings(false));
    }

    @Override
    public IModel getPageTitle() {
        return new PropertyModel(pageModel, CmsHomePage.TITLE);
    }

    @Override
    public IModel getDescription() {
        return new PropertyModel(pageModel, CmsHomePage.DESCRIPTION);

    }

    @Override
    public IModel getKeywords() {
        return new PropertyModel(pageModel, CmsHomePage.KEYWORDS);
    }

    @Override
    protected Component newTopPanel(String id) {
        return new TopMenuPanel(id, null);
    }

    @Override
    protected Component newRightPanel(String id) {
        return new EmptyPanel(id);
    }

    @Override
    protected Component newLeftPanel(String id) {
        return new EmptyPanel(id);
    }


    @Override
    protected Component newUriPanel(String id) {
        return new EmptyPanel(id);
    }


}

